package com.biwano.jsfextensions.converters;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;

import org.apache.commons.codec.digest.DigestUtils;

@FacesConverter("eu.quadran.passwordConverter")
public class PasswordConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext context, UIComponent component, String value)
			throws ConverterException {

		return DigestUtils.md5Hex(value);
	}

	@Override
	public String getAsString(FacesContext context,  UIComponent component, Object value)
			throws ConverterException {
		return null;
	}

}
